/*
 * @Author: szx
 * @Date: 2021-12-15 14:58:31
 * @LastEditTime: 2021-12-15 15:00:46
 * @Description:
 * @FilePath: \leetcode\100-199\104\104.js
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var maxDepth = function (root) {
    if (!root) return 0;
    const que = [];
    que.push(root);
    let deep = 0;
    while (que.length) {
        const length = que.length;
        for (let i = 0; i < length; i++) {
            const tmp = que.shift();
            if (tmp.left) que.push(tmp.left);
            if (tmp.right) que.push(tmp.right);
        }
        deep++;
    }
    return deep;
};
